package com.atguigu.retryer;

import feign.RetryableException;
import feign.Retryer;

// 连接超时 自定义重试类
// 指定重试的规则
public class FeignClientRetryer implements Retryer {

    int end = 10;
    int count = 1;

    // 指定重试的规则 还可以重试几次?
    @Override
    public void continueOrPropagate(RetryableException e) {
        if(end==0){
            throw new RuntimeException("重试次数过多!!!!!!!!!!!!!!!!!!!!!!");
        }
        System.out.println("当前进行了第"+count+"次重试!!!!!!!!!!!!!!!!!!");
        end--;
        count++;
    }

    @Override
    public Retryer clone() {
        // 类似于注册重试的对象
        return new FeignClientRetryer();
    }
}
